define([
	'app',
	'lodash',
	'services/TipsService',
	"resources/DoubleAuthorityResource"
	
], function(app, _ ) {

	var deps = [ '$state', 'TipsService','ConferenceAuthorityResource' ];

	function directive($state, TipsService,ConferenceAuthorityResource) {
		return {
			templateUrl: 'views/conference/conferenceAuthority.html',
			replace: true,
			scope: {
				cAuthority: '=fcConferenceAuthority'
			},
			link: function($scope) {

				$scope.changeReChargeImage=function (flag){
					var carId =$scope.cAuthority.id;
					var image =document.getElementById("changeReChargeImage"+carId);
					if(flag){
						image.src="images/recharge2.png";
					}else{
						image.src="images/recharge1.png";
					}
				};
				
				$scope.changeDeleteImage=function (flag){
					var carId =$scope.cAuthority.id;
					var image =document.getElementById("changeDeleteImage"+carId);
					if(flag){
						image.src="images/delete2.png";
					}else{
						image.src="images/delete1.png";
					}
				};
				
				
				/**
				 * 删除card
				 */
				$scope.deleteRecord = function (){
					var carId =$scope.cAuthority.id;
					ConferenceAuthorityResource.deleteConferenceAuthorityRecord(carId).success(function(result){
						$scope.$bus.publish({
							conferenceAuthority: 'conferenceAuthority',
							topic: 'remove',
							data: $scope.conferenceAuthority.id
						});
		            });
				};
				
				/**
				 * 跳转到数据记录详情页面
				 */
				$scope.goToConfDetail =function (){
					//var test =$scope.$parent.currentMenuItem.title;
					$state.go("home.confDetail", {
		                keyId: $scope.cAuthority.companyCode
		            });
				};
				
				
			}
		};
	}

	directive.$inject = deps;
	return app.lazy.directive('fcConferenceAuthority', directive);
});